Imports ccapps.persistent.authorization
Imports System.Data.SqlClient

Namespace Web.page


    Public Class ListModifiedData
        Inherits [lib].BasePage

        Protected WithEvents dgModifiedDataList As System.Web.UI.WebControls.DataGrid
        Protected WithEvents txtImei As System.Web.UI.WebControls.TextBox
        Protected WithEvents txtDealer As System.Web.UI.WebControls.TextBox
        Protected WithEvents txtProcessId As System.Web.UI.WebControls.TextBox
        Protected WithEvents lbtnFind As System.Web.UI.WebControls.LinkButton

#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub
        Protected WithEvents proc As System.Web.UI.HtmlControls.HtmlInputHidden
        Protected WithEvents Lblok As System.Web.UI.WebControls.Label
        Protected WithEvents lbtnUpdate As System.Web.UI.WebControls.LinkButton

        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration As System.Object

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

#End Region
        Private Sub Initialize()
            ' Any initialization that is dependent on passed variables MUST be done in
            ' FillVars() and not here. Initialize() is called before the variables are passed!

            Me.txtDealer.Text = ""
            Me.txtImei.Text = ""
            Me.txtProcessId.Text = ""
            Me.Lblok.Text = ""

            Dim dtModifiedDataList As DataTable = persistent.ListModifiedData.GetModifiedData
            
            Me.dgModifiedDataList.DataSource = dtModifiedDataList
            Me.dgModifiedDataList.DataBind()
            Me.dgModifiedDataList.Visible = CType(Me.dgModifiedDataList.DataSource, DataTable).Rows.Count > 0


        End Sub

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.PageTitle = "Modified Data List"

            Dim dtModifiedDataList As DataTable = persistent.ListModifiedData.GetModifiedData


            If Not Me.IsPostBack Then
                Me.dgModifiedDataList.DataSource = dtModifiedDataList
                Me.dgModifiedDataList.DataBind()
                Me.dgModifiedDataList.Visible = CType(Me.dgModifiedDataList.DataSource, DataTable).Rows.Count > 0

            End If

        End Sub

        Private Sub dgCcChangeHist_ItemCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgModifiedDataList.ItemCommand
            If (e.CommandName = "Select") Then
                Me.txtImei.Text = e.Item.Cells(3).Text.Trim()
                Me.txtDealer.Text = e.Item.Cells(2).Text.Trim()
                Me.txtProcessId.Text = e.Item.Cells(6).Text.Trim()

            End If
        End Sub


        Private Sub lbtnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbtnUpdate.Click

            Dim vStatus As String
            Dim vResult As Boolean
            If persistent.ListModifiedData.SendRequest(txtProcessId.Text.ToString(), vStatus, Me.Lblok.Text) Then
                If persistent.ListModifiedData.UpdateMasterData(txtImei.Text.ToString(), txtDealer.Text.ToString(), txtProcessId.Text.ToString(), Me.Lblok.Text) Then
                    vResult = persistent.ListModifiedData.CheckErrorCode(txtProcessId.Text.ToString(), Me.Lblok.Text)
                End If
            End If
        End Sub

    End Class
End Namespace
